package pers.wq.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import pers.wq.BaseController;
import pers.wq.model.ClassModel;
import pers.wq.model.SuperAdminModel;
import pers.wq.model.bean.ModelBean;

public class SuperAdmin extends BaseController {
	public static String TABLE_XML = "table4superadmin.xml";
	private SuperAdminModel user;
	
	public String login(){
		return this.login(user, CAT_SUPERADMIN);
	}

	public SuperAdminModel getUser() {
		return user;
	}
	
	public String classManager(){
		Map<String,Object> map = mkControllerMap("class","cid");
		return easyJson(map);
	}
	
	public String studentManager(){
		Map<String,Object> map = mkControllerMap("student", "sid");
		System.out.println(map);
		return easyJson(map);
	}
	
	public String projectManager(){
		Map<String,Object> map = mkControllerMap("project", "pid");
		return easyJson(map);
	}
	
	public String teacherManager(){
		Map<String,Object> map = mkControllerMap("teacher", "tid");
		System.out.println(map);
		return easyJson(map);
	}
	
	public String roomManager(){
		Map<String,Object> map = mkControllerMap("room", "rid");
		return easyJson(map);
	}
	
	public String attendanceManager(){
		Map<String,Object> map = mkControllerMap("attendance", "aid");
		return easyJson(map);
	}
	
	public String classStudent(){
		//1111
		String cid = ServletActionContext.getRequest().getParameter("cid");
		return easyJson(ClassModel.getClassStudent(cid));
	}
	
	protected Map<String, Object> mkControllerMap(String tableid,String idKey) {
		// TODO Auto-generated method stub
		return this.mkControllerMap(TABLE_XML, tableid, idKey);
	}

	public void setUser(SuperAdminModel user) {
		this.user = user;
	}
}
